package com.ds.dsm.view.nav.service.grid;

import com.ds.config.ResultModel;
import com.ds.config.TreeListResultModel;
import com.ds.dsm.view.config.grid.GridActionGroup;
import com.ds.enums.db.MethodChinaName;
import com.ds.esd.custom.api.annotation.APIEventAnnotation;
import com.ds.esd.custom.enums.CustomMenuItem;
import com.ds.esd.custom.module.annotation.DynLoadAnnotation;
import com.ds.esd.custom.module.annotation.ModuleAnnotation;
import com.ds.esd.custom.nav.tab.buttonviews.NavButtonViewsViewAnnotation;
import com.ds.esd.tool.ui.enums.Dock;
import com.ds.esd.util.TreePageUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/dsm/view/config/grid/group/")
public class ViewGridActionService {

    @MethodChinaName(cname = "动作事件")
    @RequestMapping(method = RequestMethod.POST, value = "GridActionGroup")
    @DynLoadAnnotation
    @NavButtonViewsViewAnnotation
    @APIEventAnnotation(bindMenu = CustomMenuItem.treeNodeEditor)
    @ModuleAnnotation(caption = "动作事件", imageClass = "spafont spa-icon-action", dock = Dock.fill)
    @ResponseBody
    public ResultModel<GridActionGroup> getGridActionGroup(String sourceClassName, String methodName, String domainId, String viewInstId) {
        ResultModel<GridActionGroup> result = new ResultModel<GridActionGroup>();
        return result;
    }

    @RequestMapping(method = RequestMethod.POST, value = "GridEventMenuItems")
    @ModuleAnnotation(dynLoad = true, caption = "动作事件", imageClass = "bpmfont bpmgongzuoliuxitongpeizhi", index = 0)
    @APIEventAnnotation(bindMenu = CustomMenuItem.loadChild)
    @ResponseBody
    public TreeListResultModel<List<GridNavTree>> getGridEventMenuItems(String domainId, String sourceClassName, String methodName, String viewInstId) {
        TreeListResultModel<List<GridNavTree>> result = new TreeListResultModel<>();
        result = TreePageUtil.getTreeList(Arrays.asList(GridEventMenuItems.values()), GridNavTree.class);
        return result;
    }

}
